package com.offer;


public class Test53_2 {

    public int missingNumber(int[] nums) {
        int left = 0, right = nums.length - 1;

        while (left <= right) {
            int mid = (right - left) / 2 + left;
            if (mid == nums[mid]) {
                left = mid + 1;
            } else {
                right = mid - 1;
            }
        }
        return left;
    }


    public static void main(String[] args) {
        Test53_2 test = new Test53_2();
//        System.out.println(test.missingNumber(new int[]{0, 1, 3}));
        System.out.println(test.missingNumber(new int[]{0, 2, 3, 4, 5, 6, 7, 8, 9}));
//        DataUtils.printListNode(test.reserveList(a));
    }

}
